package com.t2t.top.framework.rocketmq.client.extension;

import java.io.Serializable;

import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.MQProducer;
import com.alibaba.rocketmq.client.producer.SendCallback;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.remoting.exception.RemotingException;

public interface MessageProducer {

	/**
	 * 这里很重要：一定要把消息上抛,用于业务代码的事务控制或重试
	 * 
	 * @throws InterruptedException
	 * @throws MQBrokerException
	 * @throws RemotingException
	 * @throws MQClientException
	 */
	public <E extends Serializable> SendResult send(String key, E messageObject) throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
	
	/**
	 * 异步消息
	 * @param key
	 * @param messageObject
	 * @param sendCallback
	 * @throws MQClientException
	 * @throws RemotingException
	 * @throws InterruptedException
	 */
	public <E extends Serializable> void send(String key, E messageObject, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException;
	
	public SendResult send(String key, byte[] message) throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
	
	public MQProducer getMQProducer();

}